import request from '@/utils/request.js'
import tools from '@/utils/tools.js'

/*订单api*/




//查询订单列表
export function getOderList(data) {
	return request({
		url: '/order/order/orderList',
		method: 'POST',
		data
	})
}

//创建图鉴订单
export function createPictuireOrder(data) {
	return request({
		url: '/order/pay/createPictuireOrder ',
		method: 'POST',
		data
	})
}


//创建一级市场订单
export function createOrder(data) {
	return request({
		url: '/order/pay/CreateOrder',
		method: 'POST',
		data
	})
}


//创建二级市场订单
export function createMarketOrder(data) {
	return request({
		url: '/order/pay/CreateMarketOrder',
		method: 'POST',
		data
	})
}


/**
 * 订单详情
 */
export function getOrderDetails(id, order_type = 1) {
	let url = `/order/order/orderDetail/ids/${id}`
	if (order_type == '2') {
		url = `/order/order/MarketOrderDetail/ids/${id}`
	}
	return request({
		url,
		method: 'post',
	})
}

/**
 * 赠送订单详情https://api.bainiu.art/api/order/order/giveOrderDetail/ids/4
 */
export function getRegiftOrderDetails(id) {
	let url = `/order/order/giveOrderDetail/ids/${id}`
	return request({
		url,
		method: 'post',
	})
}
/*
 *获取我的寄售订单详情
 **/
export function getMarketOrderDetails(order_id) {
	return request({
		url: '/order/order/saleMarketOrderDetail',
		method: 'post',
		data: {
			order_id
		}
	})
}


/**
 * 修改订单状态
 **/
export function changeOrderStatus(data) {
	//订单类型 1普通市场 2二级市场
	const {
		order_type
	} = data;
	let url = '/order/order/changeOrderStatus'
	if (order_type == '2') {
		url = '/order/order/changeMarketOrderStatus'
	} else if (order_type == 19) {
		url = '/order/order/changeGiveOrderStatus'
	}
	return request({
		url,
		method: 'post',
		data
	})
}





/**
 *支付 
 * @param {Object} data 
 */
export function doPay(data) {
	return request({
		url: '/order/pay/doPay',
		method: "POST",
		data
	})
}


/**
 * 抽签报名
 * @param {*} data 
 */
export function signUpDraw(data) {
	return request({
		url: '/order/pay/doQualification',
		method: "POST",
		data
	})
}


/**
 * 查询抽签状态
 * @param {*} data 
 */
export function queryDrawStatus(data) {
	return request({
		url: '/order/pay/lookQualification',
		method: "POST",
		data
	})
}

/**
 * 查询报名抽签列表
 * @param {*} data 
 */
export function queryDramOrSignUpList(data) {
	return request({
		url: '/order/pay/qualification',
		method: "POST",
		data
	})
}

/*
快捷下单
*/
export async function fastCreateOrder(data, validate) {
	// data = await tools.encode(data);
	return request({
		url:'/order/pay/fastOrderNew',
		method: "POST",
		// header:{
		// 	"content-type":"form-data;"
		// },
		data
	})

}

//批量下单
export function bacthCreateOrder(data) {
	// data=await tools.encode(data);
	return request({
		url:'/order/pay/batchBuy',
		method: "POST",
		data
	})
}

//取消批量下单
export function cancelBatchOrder(data) {
	return request({
		url: '/order/order/cancelbatchorder',
		method: "POST",
		data
	})
}


//获取批量下单订房单列表
export function getBatchOrderList() {
	return request({
		url: '/order/order/batchPayOrder',
		method: "POST",
	})
}


//创建批量支付订单
export function createBatchPayOrder(data) {
	return request({
		url: '/order/pay/batchdopay',
		method: "POST",
		data
	})
}


//图鉴订单
export function pictureOrderList(data) {
	return request({
		url: '/order/order/pictureOrderList',
		method: "POST",
		data
	})
}

//图鉴取消订单
export function canclepictureOrder(data) {
	return request({
		url: '/order/order/canclepictureOrder',
		method: "POST",
		data
	})
}

// 寄售订单
export function getMarketOrderList(data) {
	return request({
		url: '/order/order/sale_order_list',
		method: "POST",
		data
	})
}